vpath %.cpp ../../Source

CXX = g++
RM = rm
BUILD_DIR = ../../Build/cygwin
OUTPUT_DIR = ../../Output/cygwin
CXXFLAGS = -std=c++11 -g

prog = main
src = main.cpp \
	  I01_TemplateTypeDeduction.cpp \
	  I02_AutoTypeDeduction.cpp \
	  I03_Understand_decltype.cpp \
	  I05_PreferAutoToExplicitType.cpp \
	  I06_ProblemOfAuto.cpp \
	  I07_initializerFormat.cpp \
	  I08_PreferNullptrTo0_NULL.cpp \
	  I09_PreferAliasToTypedef.cpp \
	  I10_PreferScopedEnumsToUnscoped.cpp \
	  I11_PreferDeletedFunctionsToPrivateUndefinedOnes.cpp \
	  I12_DeclareOverridingFunctionsOverride.cpp \
      I13_PreferConst_iteratorToIterator.cpp \
	  I14_UseConstexpr.cpp \
	  I15_MakeConstMemberFunctionsThreadSafe.cpp \
	  I16_DeclareFunctionsNoexcept.cpp \
	  I17_ConsiderPassByValueOnSomeConditions.cpp \
	  I18_ConsiderEmplacementInsteadOfInsertion.cpp \
	  I19_SpecialMemberFunctionGeneration.cpp
	  
objects = $(patsubst %.cpp,$(BUILD_DIR)/%.o,$(src)) 

.PHONY: all
all: $(OUTPUT_DIR)/$(prog)

$(objects): | $(BUILD_DIR)

$(OUTPUT_DIR)/$(prog): | $(OUTPUT_DIR)

$(OUTPUT_DIR)/$(prog) : $(objects)
	@echo linking $(prog)...
	@$(CXX) $(LDFLAGS) -o $@ $(objects)

.PHONY: clean
clean:
	-@$(RM) -f $(objects) $(prog) 2> /dev/null	
	
$(BUILD_DIR):	
	@mkdir -p $@
	
$(OUTPUT_DIR):
	@mkdir -p $@

$(BUILD_DIR)/%.o : %.cpp
	@echo compile $<
	@$(CXX) $(CXXFLAGS) -c $< -o $@

      